<%@ page language="Java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="java.sql.*"%>
<html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">    
    <title>JDBC的连接过程</title>        
 </head>
 <body>
 <%
 	try{
 		Class.forName("com.mysql.jdbc.Driver");
 		String url = "jdbc:mysql://localhost:3306/test";
 		String username = "root";
 		String password = "1234";
 		Connection conn = DriverManager.getConnection(url,username,password);
 		if(conn != null){
 			out.println("数据库连接成功");
 			conn.close();
 		}else{
 			out.println("数据库连接失败");
 		}
 	}catch(ClassNotFoundException e){
 		e.printStackTrace();
 	}catch(SQLException e){
 		e.printStackTrace();
 	}
 %>
 </body>
</html>